<?php
/**************************************************************************************************
|
| AudioShare - Audio Sharing Script
| http://www.audiosharescript.com
| webmaster@audiosharescript.com
|
|**************************************************************************************************
|
| By using this software you agree that you have read and acknowledged our End-User License 
| Agreement available at http://www.audiosharescript.com/eula.html and to be bound by it.
|
| Copyright (c) 2010 AudioShareScript.com. All rights reserved.
|**************************************************************************************************/

include("include/config.php");
include("include/functions/import.php");

//FEATURED AUDIOS BEGIN
$home_feat_audios = $config['home_feat_audios'];
$query="SELECT AUDIOID,title,ext,date_added,categories FROM audios WHERE public='1' AND active='1' AND featured='1' ORDER BY rand() limit $home_feat_audios";
$executequery = $conn->Execute($query);
if($executequery->recordcount()>0)
$raudios = $executequery->getrows();
$catName=fetch_category_name_from_id($raudios[0]["categories"]);
$audio_year=date("Y",strtotime($raudios[0]["date_added"]));

STemplate::assign('catName',$catName);
STemplate::assign('audio_year',$audio_year);
STemplate::assign('raudios',$raudios);
//FEATURED AUDIOS END

//RECENT AUDIOS BEGIN
$home_rec_audios = $config['home_rec_audios'];
$query="SELECT AUDIOID,title,ext,viewcount,featured FROM audios WHERE public='1' AND active='1' ORDER BY AUDIOID desc limit $home_rec_audios";
$executequery = $conn->Execute($query);
if($executequery->recordcount()>0)
$faudios = $executequery->getrows();
STemplate::assign('faudios',$faudios);
//RECENT AUDIOS END

//MOST VIDEOS AUDIOS BEGIN
$home_view_audios = 20;
//$query="SELECT distinct a.AUDIOID,title,ext,count(a.AUDIOID) as viewcount,username,a.featured,a.artist FROM audios AS a LEFT JOIN audios_viewed av on (a.AUDIOID=av.AUDIOID) LEFT JOIN members AS m ON m.USERID = a.USERID WHERE public='1' AND active='1' and av.date_viewed >= DATE_SUB(CURDATE(),INTERVAL 7 DAY) ORDER BY viewcount desc limit $home_view_audios";
$query="SELECT a.AUDIOID,title,ext,count(a.AUDIOID) as viewcount,username,a.artist FROM audios AS a LEFT JOIN members AS m ON m.USERID = a.USERID left join audios_viewed av on av.AUDIOID=a.AUDIOID WHERE public='1' AND active='1' and av.date_viewed >= DATE_SUB(CURDATE(),INTERVAL 7 DAY) group by av.AUDIOID ORDER BY viewcount desc limit 20";
$executequery = $conn->Execute($query);
if($executequery->recordcount()>0)
$vaudios = $executequery->getrows();
STemplate::assign('vaudios',$vaudios);
//MOST VIDEOS AUDIOS END

$pagetitle = "$lang[173]";
STemplate::assign('pagetitle',$pagetitle);

//TEMPLATES BEGIN
STemplate::display('home.tpl');
STemplate::display('footer.tpl');
//TEMPLATES END
?>